#include <iostream>
#include <string>
#include <stack>
#include <map>

using namespace std;


int main(){
	string n,c = "true";
	map<char,char> braces;  //={{')','('},{']','['},{'}','{'}};
	braces[')']='(';
	braces[']']='[';
	braces['}']='{';
	char m;
	stack<char> s;
	s.push('u');
	cin>>n;
	for(int i=0;i < n.length()-1;i++){
		m = n[i];
		if(m == '('   ||   m == '['   ||   m == '{'){
			s.push(m);
			//cout<<"push "<<m<<" and now top="<<s.top()<<" size="<<s.size() <<endl; 
		}
		else if(m == ')'   ||   m == ']'   ||   m == '}'){
			if(braces[m] != s.top()){
				c = "false";
				break;
			}else{
			//	cout<<"pop "<<s.top()<<" and now size=";
				s.pop();
			//	cout<<s.size()<<endl; 
			}
		}
	}
	if(c == "false"   ||   s.size() != 1){
		cout<<"NO";
	}
	else{
		cout<<"YES";
	}
}
